﻿using Newtonsoft.Json;
using NotesVaultOnline.Data.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace NotesVaultOnline.Controllers
{
    [Authorize]
    public class NoteController : Controller
    {
        public string Upload(string data)
        {
            var result = new CustomResult { Type = CustomResult.ResultType.Error, Message = "Fail to upload the file. Please try again." };
            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];
                result.Data = file.FileName;
                result.Type = CustomResult.ResultType.Success;
                result.Message = "File uploaded successfully.";
            }
            return JsonConvert.SerializeObject(result);
        }
    }
}
